# $Id$
# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgbase=libmygpo-qt
pkgname=(libmygpo-qt4 libmygpo-qt5)
pkgver=1.1.0
pkgrel=1
pkgdesc='A C++/Qt client library for gpodder.net'
arch=('x86_64')
url="http://wiki.gpodder.org/wiki/Libmygpo-qt"
license=('LGPL2.1')
depends=('qjson')
makedepends=('cmake' 'doxygen' 'qjson' 'qt5-base')
source=("http://stefan.derkits.at/files/libmygpo-qt/libmygpo-qt.${pkgver}.tar.gz"
        libmygpo-qt5.11a.patch::"https://github.com/gpodder/libmygpo-qt/commit/0d76d960.patch"
        libmygpo-qt5.11b.patch::"https://github.com/gpodder/libmygpo-qt/commit/1b53767b.patch")
sha256sums=('82765a9baa7b6bb3a3277759cec9c3779eee691db9180affe35a67813346e1cd'
            '4894360b246edd38024b8a60b66e3219494655e9d5ed7b3ed7f03958b796ac98'
            'a4d02a6d15eef8ce08888a4090f5cbb50f744d8af85011ee8e54e84e99756e75')

prepare() {
  cd libmygpo-qt.${pkgver}
  patch -p1 -i ../libmygpo-qt5.11a.patch # Fix build with Qt 5.11
  patch -p1 -i ../libmygpo-qt5.11b.patch
  cd ..

  if [[ -d build ]]; then
    rm -rf build
  fi
  mkdir build{4,5}
}

build() {
  cd build4
  cmake ../libmygpo-qt.${pkgver} \
    -DCMAKE_BUILD_TYPE='Release' \
    -DCMAKE_INSTALL_PREFIX='/usr' \
    -DBUILD_WITH_QT4=ON
  make

  cd ../build5
  cmake ../libmygpo-qt.${pkgver} \
    -DCMAKE_BUILD_TYPE='Release' \
    -DCMAKE_INSTALL_PREFIX='/usr' \
    -DMYGPO_BUILD_TESTS=OFF
  make
}

package_libmygpo-qt4() {
  depends=('qjson')
  conflicts=('libmygpo-qt')
  provides=('libmygpo-qt')
  replaces=('libmygpo-qt')
  cd build4

  make DESTDIR="${pkgdir}" install
}

package_libmygpo-qt5() {
  depends=('qt5-base')
  cd build5

  make DESTDIR="${pkgdir}" install
}

# vim: ts=2 sw=2 et:
